home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 803 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  49 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: "joe (j.) halpin" <jhalpin@bnr.ca>
  3. Newsgroups: comp.std.c++
  4. Subject: Referencing pointers after delete
  5. Date: 21 Mar 1996 16:29:49 GMT
  6. Organization: Bell-Northern Research, Richardson, TX
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4is05t$ceo@engnews1.Eng.Sun.COM>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Content-Length: 1158
  11. X-Lines: 38
  12. Cc: 
  13. Originator: clamage@taumet
  14.  
  15. To Moderator: This may be a duplicate, my newsreader software was having
  16. trouble sending this, so I'm mailing it as well.
  17.  
  18. In 3.7.3.2.4 the January working paper says:
  19.  
  20. 4 A deallocation function can free the storage referenced by the pointer
  21.   given  as  its  argument and renders the pointer invalid.  The storage
  22.   can be made available for further allocation.  An invalid pointer con-
  23.   tains an unusable value:  it cannot even be used in an expression.
  24.  
  25. This sounds as though, in the following:
  26.  
  27. char *pc = new char[128];
  28. delete pc;
  29. pc = 0;
  30.  
  31. it makes the final assignment (an expression) invalid.
  32.  
  33. Am I misunderstanding something, or is it illegal to zero out pointers
  34. after they've been deallocated? I'm assuming that the intent was to
  35. disallow dereferencing of pointers that have been handed to
  36. delete. The wording seems to disallow the above as well.
  37.  
  38. In fact, it sounds like it also rules out things like 'if(pc == 0)
  39. ...' after the above fragment.
  40.  
  41. Joe
  42.  
  43.  
  44. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  45. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  46. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  47. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  48. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  49.